package com.lujieni.controller;

import com.lujieni.domain.vo.StudentVO;
import com.lujieni.domain.po.StudentPO;
import com.lujieni.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;

@RestController
public class StudentController {

    @Autowired
    private IStudentService studentService;
    @Autowired
    private ApplicationContext applicationContext;

    @RequestMapping(value = "/v1/findStudentByName", method = RequestMethod.GET)
    public List<StudentVO> findStudentByName(){
        return studentService.findStudentByName();
    }

    @RequestMapping(value = "/v1/findAllStudent", method = RequestMethod.GET)
    public List<StudentPO> findAllStudent()  throws Exception{
        List<StudentPO> result = ((Mapper) applicationContext.getBean(Class.forName("com.lujieni.dao.StudentDao"))).selectAll();
        return result;
    }

}
